#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <limits.h>
#include <ctype.h>

int
is_palindrom(int n)
{
	register int x = n, y = 0;

	while (x > 0) {
		y *= 10;
		y += x % 10;
		x /= 10;
	}

	if (y == n)
		return 1;
	else
		return 0;
}

int
divisors_sum(int n)
{
	int ret = 0;
	register int i = 1;

	for (; i < n / 2 + 1; ++i) {
		if (n % i == 0)
			ret += i;
	}

	ret += n;

	return ret;
}

int
digit_sum(int n)
{
	int sum = 0;

	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}

	return sum;
}

int
main(int argc, char **argv)
{
	int a, b;
	int i;

	scanf("%d%d", &a, &b);

	for (i = a; i <= b; i++) {
		if (is_palindrom(i) && (divisors_sum(i) % digit_sum(i) == 0)) {
			printf("%d ", i);
		}
	}

	fputc('\n', stdout);

	return 0;
}
